import request from '../../utils/request';

/**
 * 获取识别信息
 */
export function fetch() {
    return request(is.CONST.urls.recognize);
}

/**
 * 保存识别信息
 */
export function save(recognize) {
    return request(is.CONST.urls.recognize, {
        method: recognize.method || 'POST',
        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
        body: JSON.stringify(recognize),
    });
}

/**
 * 更改资源类型和标题
 * 模拟表单提交
 */
export function updateResource(cateId, resourceTagTitle) {
    return request(is.CONST.urls.edit_resource, {
        method: 'PUT',
        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
        body: `cate_id=${cateId}&resource_tag_title=${resourceTagTitle}`,
    });
}

export default {
    fetch,
    save,
    updateResource,
};
